﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace Mathematics.Calculus
{
    public static class Derivatives
    {
        //public static BinaryExpression Derive(this BinaryExpression target, int order)
        //{
        //    BinaryExpression intermediate = target;
        //    for (int i=0;i<order;i++)
        //    {
        //        intermediate = Derive(intermediate);
        //    }
        //    return intermediate;
        //}

        //public static BinaryExpression Derive(this BinaryExpression target)
        //{
        //    switch (target.NodeType)
        //    {
        //        case ExpressionType.Power:
        //            return DerivePower(target);
        //        case ExpressionType.Add:

        //    }
        //}

        //private static BinaryExpression DerivePower(BinaryExpression target)
        //{
        //    var baseTerm = target.Left;
        //    var exponentTerm = target.Right;

        //    var expMinusOne = Expression.Subtract(exponentTerm, Expression.Constant(-1));
        //    var newPower = Expression.Power(baseTerm, expMinusOne);
        //    var product = Expression.Multiply(exponentTerm, newPower);

        //    return product;
        //}

        //private static BinaryExpression DeriveAnd(BinaryExpression target)
        //{
            
        //}
    }
}
